package com.demo.model;
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;


//公共类
@Component
public class Users {
    //公共对象，默认单例模式
    @Bean(name = "user")
//    @Scope("prototype")//直接设置使其变为原型模式|多例模式
    @Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)//使用全局变量设置
    public User getUser(){
        User user=new User();
        user.setId(1);
        user.setName("10086");
        return user;
    }
}
